<?php

namespace frontend\modules\common\behavior;

use yii\base\Behavior;
use yii\web\Controller;


class DisableCsrf extends Behavior
{
    public $actions = [];
    public $controller;

    public function events()
    {
        return [Controller::EVENT_BEFORE_ACTION => 'beforeAction'];
    }

    public function beforeAction($event)
    {
        $action = $event->action->id;
        if (in_array($action, $this->actions)) {
            $this->controller->enableCsrfValidation = false;
        }
    }
}